package com.study.testSpringBoot.mina;

import org.apache.mina.core.service.IoHandlerAdapter;
import org.apache.mina.core.session.IoSession;

public class MinaClientHandler extends IoHandlerAdapter {

	private final String values;  
	
	public MinaClientHandler(String values) {  
		this.values = values;  
	}  
	
	@Override  
	public void sessionOpened(IoSession session) {  
		session.setAttribute("test", "wuyu");
		session.write(values);  
		//调用IoService的dispose方法关闭线程
		//注释掉，不然没法接送服务端的响应数据
//		IoService service = session.getService();
//        service.dispose();
	} 
    
	@Override
	public void messageReceived(IoSession session, Object message) throws Exception {
		System.out.println("收到服务器响应消息：" + message);
	}
}
